home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / HippoDraw / HippoDrawSrc1.1 / Hippo.subproj / Plot.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-25  |  8.5 KB  |  373 lines

  1. /* Plot.h  by Jonas Karlsson, July 1990 
  2.  *
  3.  * Copyright (C)  1991  The Board of Trustees of
  4.  * The Leland Stanford Junior University. All Rights Reserved.
  5.  */
  6.  
  7. #define PLOT_H_ID "$Id: Plot.h,v 1.13 1992/04/22 00:22:27 pfkeb Rel $"
  8.  
  9. #import <objc/hashtable.h>
  10. #import "hippo.h"
  11. #import "Graphic.h"
  12.  
  13. struct cutParmType  
  14. {
  15.     char               *cutFunc;
  16.     int                 varIndex;
  17.     float               cutValue1;
  18.     float               cutValue2;
  19.     int                 cutCode;
  20.     int            blkSize;
  21. };
  22. typedef struct cutParmType cutParmType;
  23.  
  24. typedef struct cutStorElem_t {
  25.     id        plot;
  26.     NXAtom    name;
  27.     func_id    function;
  28.     } cutStorElem;
  29.     
  30. typedef struct dependStorElem_t {
  31.     id        plot;
  32.     NXAtom    name;
  33.     } dependStorElem;
  34.     
  35. @interface Plot:Graphic
  36. {
  37.     id        graphicView;    /* The View object in which drawing is done */
  38.     id        hTuple;        /* HTuple object for ntuple bound to display */
  39.     display     disp;
  40.     BOOL        cutHistFlag;
  41.     char        *reffilename;    /* filename of tuple referenced */
  42.     int        ntindex;    /* index to n-tuple in file */
  43.     BOOL        refFlag;    /* reference state before archiving */
  44.     BOOL        fixBinsFlag;    /* fixed bins state before archiving */
  45.     NXAtom    uniqueName;    /* unique name of plot */
  46.     
  47.  /* data on plots used to make cut on this plot */
  48.     id        cutPlotStor;    /* Storage for cut Plots and func.*/
  49.     id        cutPlotList;    /* temporary List of cut Plots */
  50.     
  51.  /* data used by Plot used for a Cut */
  52.     id        dependStor;    /* List of dependent Plots */
  53.     id        dependList;    /* temporary List of dependent Plots */
  54.     cutParmType cutParms;
  55.     int         cutNumber;    /* No longer used, but archived */
  56. }
  57.  
  58.  
  59. + initialize;
  60.  /*
  61.   * Class initializer.   Sets version number of Class.
  62.   */
  63.   
  64. - init;
  65.  
  66. - (const char *)name;
  67.  /*
  68.   * Retruns the unique name for the receiving object
  69.   */
  70.   
  71. - setGraphicView:anObject;
  72.   /*
  73.    * Sets the graphic View object of the receiver.
  74.    */
  75.    
  76. - graphicView;
  77.  /*
  78.   * Returns the view that receiving object is being displayed in.
  79.   */
  80. - setHTuple: ht withDisplay:(display) d1;
  81.   /* Sets the ntuple handler and display hippo structures */
  82.   
  83. - setRefFilename:(const char *)filename;
  84.  /*
  85.   * Sets the name of the reference n-tuple file
  86.   */
  87.   
  88. - changeRefFileNameIfValid:(const char *)filename;
  89.  /*
  90.   * Change the reference file name if it is a valid change.   A 
  91.   * valid change is one in which the n-tuple for the plot did not
  92.   * come from a file, i.e. it either came from pasteboard or from
  93.   * another part of the application.
  94.   */
  95.   
  96. - getDispType:(graphtype_t *) type;
  97. - setDispType:(graphtype_t *) type;
  98.  
  99. - closeTuple;
  100.   /*
  101.    * Un-binds the display from the n-tuple.
  102.    */
  103.    
  104. - bindReference;
  105.   /*
  106.    * Attempts to bind the plot and its display to ntuple using its archived
  107.    * reference filename.  This method is used for inserting a plot
  108.    * when reading document or when pasting from PasteBoard.
  109.    */
  110.       
  111. - bindCuts;
  112.   /*
  113.    * Attempts to bind the plot with its cuts, or its cut dependents.
  114.    * Should be invoked only after all plots have been bound.
  115.    */
  116.    
  117. - setRefFlag:(BOOL) refFlag;
  118.   /*
  119.    * Sets state of display's ntuple reference
  120.    */
  121.    
  122. - setFixBinsFlag:(BOOL)flag;
  123.  /*
  124.   * Sets the fixed bins flag.
  125.   */
  126.   
  127. - replaceTupleWith: ht;
  128.   /* Replaces the tuple handler of the display with new handler n1.
  129.    */
  130.    
  131. - replace:oldTuple with:newTuple;
  132.  /*
  133.   * If oldTuple is the HTuple object for receiving Plot, then it
  134.   * is replaced with newTuple.   returns self;
  135.   */
  136.   
  137. - hTuple;
  138.   /*
  139.    * Returns the n-tuple handler object for display.
  140.    */
  141.    
  142. - (ntuple) ntuple;
  143.   /* Returns the ntuple */
  144.  
  145. - addHTupleToList:tlist;
  146.   /*
  147.    * Adds the receiving object's hTuple to list tlist.
  148.    */
  149.    
  150. - addPlotToList:list;
  151.   /*
  152.    * Receiving plot adds itself to the List list.
  153.    */
  154.    
  155. - (display) histDisplay;
  156.   /* Returns the Hippo display */
  157.   
  158. - NameAxisX:(const char *)AxisName;
  159. - NameAxisY:(const char *)AxisName;
  160. - NameAxisW:(const char *)AxisName;
  161. - NameAxisXE:(const char *)AxisName;
  162. - NameAxisYE:(const char *)AxisName;
  163.  /*
  164.   * Set the label of the axes.
  165.   */
  166.  
  167. - (const char *) axisLabelX;
  168.  /*
  169.   * Returns the x-axis label
  170.   */
  171.  
  172. - (const char *) axisLabelY;
  173.  /*
  174.   * Returns the y-axis label
  175.   */
  176.  
  177. - bindAxisX:(int *)dataDim;
  178.   /* Binds the X axis to data dimension dataDim.
  179.    */
  180.    
  181. - bindAxisY:(int *)dataDim;
  182.   /* Binds the Y axis to data dimension dataDim.
  183.    */
  184.    
  185. - bindAxisW:(int *)dataDim;
  186.   /* Binds the weight to data dimension dataDim.
  187.    */
  188.  
  189. - bindAxisXE:(int *)dataDim;
  190.   /* Binds the X error to data dimension dataDim.
  191.    */
  192.  
  193. - bindAxisYE:(int *)dataDim;
  194.   /* Binds the Y error to data dimension dataDim.
  195.    */
  196.  
  197. - setLogScaleX:(int *)yesOrNo;
  198. - (BOOL) isLogScaleX;
  199.  /*
  200.   * Returns YES if x-axis is display a log scale.
  201.   */
  202.  
  203. - setLogScaleY:(int *)yesOrNo;
  204.     /*  sets log scale for this display */
  205.     
  206. - (BOOL) isLogScaleY;
  207.  /*
  208.   * Returns YES if x-axis is display a log scale.
  209.   */
  210.  
  211. - setAutoScaleX:(int *)yesOrNo;
  212. - setAutoScaleY:(int *)yesOrNo;
  213.  
  214. - setTitlesFlag:(int *)yesOrNo;
  215.  /*
  216.   * Sets titles and labels drawing on or off
  217.   */
  218.  
  219. - (int) titlesFlag;
  220.  /*
  221.   * Returns YES if titles and labels are being drawn
  222.   */
  223.  
  224. - setAxesFlag:(int *)yesOrNo;
  225.  /*
  226.   * Sets drawing of axes on or off
  227.   */
  228.  
  229. - (int) axesFlag;
  230.  /*
  231.   * Returns YES if axes are being drawn.
  232.   */
  233.   
  234. - setCutHistFlag: (BOOL) yesOrNo;
  235.  /*
  236.   * Shows type of this plot. If it is a Cut Histogram, we handle it differently
  237.   */
  238.  
  239. - (BOOL) isCutHist;
  240.     /* returns YES or NO */
  241.  
  242. - setNumBinsForAxisX:(int *) n;
  243.   /* 
  244.    * Changes the number of bins for axis X to n bins
  245.    */
  246.    
  247. - setNumBinsForAxisY:(int *) n;
  248.   /* 
  249.    * Changes the number of bins for axis Y to n bins
  250.    */
  251. - (int) numBinsForAxis:(binding_t) axis;
  252. - (float) widthForAxis:(binding_t) axis;
  253. - setRangeForAxisX:(NXPoint *)p;
  254. - getRangeForAxisX:(NXPoint *)p;
  255. - setRangeForAxisY:(NXPoint *)p;
  256. - getRangeForAxisY:(NXPoint *)p;
  257. - getRangeForAxisY:(NXPoint *)p normalizedTo:plot;
  258.  /*
  259.   * Returns, by reference, the range of the y axis.   If both the receiving
  260.   * plot and plot are of graphtype HISTOGRAM, the the returned range
  261.   * is normalized to take into account the bin width.
  262.   */
  263.   
  264. - getRangeForAxis:(binding_t) axis low:(float *) xl high:(float *) xh;
  265. - setRangesFrom:plot;
  266.  /*
  267.   * Receiving plot sets x and y ranges to correspond to those of plot.
  268.   * If bot plots are graphtype HISTOGRAM, then receiving plot will
  269.   * take into account the bin width
  270.   */
  271. - setDrawType:(drawtype_t *) type;
  272. - getDrawType:(drawtype_t *) type;
  273. - setColorType:(int *) onOff;
  274. - (char *) title;
  275.   /* Returns the title of the Histogram display
  276.    */
  277.  
  278. - print;
  279.   /* Generates line printer output to stdout
  280.    */
  281.    
  282. - draw;
  283. - setBounds:(const NXRect *)aRect;
  284. - sizeToNaturalAspectRatio;
  285.  /*
  286.   * Sets size to default plot size keeping the upper left corner
  287.   * at its current postion.
  288.   */
  289. /* Methods supporting managing cutPlots to this plot */
  290. - addCutPlot: cutPlot;
  291.  /*
  292.   * Adds a plot being used to display cuts to list of cut plots
  293.   */
  294.   
  295. - changeCutPlot:cutPlot;
  296.  /*
  297.   * Informs receiving Plot that the plot cutPlot has changed the
  298.   * cut function parameters.   
  299.   */
  300.   
  301. - removeCutPlot:cutPlot;
  302.  /*
  303.   * Receiving Plot removes cutPlot from list of plots that apply
  304.   * cut to its display.
  305.   */
  306.     
  307. - removeAllCuts;
  308.  /*
  309.   * Receiving Plot removes all cuts.
  310.   */
  311.   
  312. - cutList;
  313.  /*
  314.   * Returns the list of plots being used to display the cuts on the
  315.   * receiving object.
  316.   */
  317.    
  318. - (BOOL) hasCut;
  319.  /*
  320.   * Returns YES if a cut is being applied to the display
  321.   */
  322.   
  323. /* Methods used to support plot being used for display for a cut function */
  324. - setCutParms:(cutParmType *) parms;
  325.  /*
  326.   * Sets the cut parameters for Plot being used to display cut function.
  327.   */
  328.   
  329. - getCutParms:(cutParmType *) parms;
  330.  /*
  331.   * Returns the cut parameters for cut functions being displayed by
  332.   * receiving object.
  333.   */
  334.   
  335. - addCutDepend:sender;
  336.  /*
  337.   * Receiving object adds sender to list of Plots that depends
  338.   * on its cut control.
  339.   */
  340.   
  341. - removeCutDepend:sender;
  342.  /*
  343.   * Removes the sender from list of Plots depending on receiver's
  344.   * cut control.
  345.   */
  346.   
  347. - (unsigned) dependCount;
  348.   /*
  349.    * Returns the number of Plot objects depending on the receiving 
  350.    * object to control its cut
  351.    */
  352.    
  353. - dependList;
  354.  /*
  355.   * Returns a List object containing those Plots that depend on
  356.   * receiving objects cut paramaters.
  357.   */
  358.   
  359. - (BOOL) isCutPlot;
  360.  /*
  361.   * Returns YES if receiving Plot is a plot that displays a cut,
  362.   * NO otherwise.
  363.   */
  364.   
  365. /* Methods supporting Archiving and de-Archiving */
  366. - write:(NXTypedStream *) ts;
  367. - read:(NXTypedStream *) ts;
  368. - free;
  369.   /* frees the Hippo display (but not the tuple) and frees itself
  370.    */
  371.  
  372. @end
  373.